import NProgress from "nprogress"
import 'nprogress/nprogress.css'
import { createRouter, createWebHashHistory } from "vue-router";

const routes = [
    {
        path: "/",
        redirect: "/login"
    },
    {
        path: "/home",
        name: "首页",
        component: () => import("../pages/Home.vue"),
        redirect:"/home/dashboard",
        children: [{
            path: "user",
            name: "用户管理",
            component: () => import("../pages/UserInfo.vue")
        },{
            path:"user/add",
            name:"用户添加",
            component:()=>import("../pages/UserAdd.vue")
        },{
            path:"word",
            name:"文档编写",
            component:()=>import("../pages/EditWord.vue")
        },{
            path:"person",
            name:"个人信息",
            component:()=>import("../pages/PersonInfo.vue")
        },{
            path:"dashboard",
            name:"仪表盘",
            component:()=>import("../pages/DashBoard.vue")
        },{
            path:"permission",
            name:"权限信息",
            component:()=>import("../pages/PermissionInfo.vue")
        },{
            path:"role",
            name:"角色信息",
            component:()=>import("../pages/RoleInfo.vue")
        }]
    },
    {
        path: "/login",
        name: "登录",
        component: () => import("../pages/Login.vue")
    },
    {
        path: "/register",
        name: "注册",
        component: () => import("../pages/Register.vue")
    }
]

const router = createRouter({
    history: createWebHashHistory(),
    routes
})

router.beforeEach(async (toString, formItemProps, next) => {
    NProgress.start();
    next();
})

router.afterEach(async () => {
    NProgress.done();
})

export default router;